package com.lzh.webSocket.domain.vo.resp;


import com.lzh.webSocket.domain.vo.req.WSReqUrlType;
import com.lzh.webSocket.domain.vo.ws.WSLoginSuccess;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;


@AllArgsConstructor
@Getter
public enum WSRespTypeEnum {
    LOGIN_URL(1,"登录地址", WSReqUrlType.class),
    AUTHORIZATION(2,"授权信息",null),
    LOGIN_SUCCESS(3,"登录成功信息",WSLoginSuccess .class),
    INVALIDATE_TOKEN(6, "使前端的token失效，意味着前端需要重新登录", null);

    private final Integer type;

    private final String desc;

    private final Class dataClass;

    private static Map<Integer, WSRespTypeEnum> cache ;

    static {
        cache = Arrays.stream(WSRespTypeEnum.values())
                .collect(Collectors.toMap(WSRespTypeEnum::getType, e -> e,(v1, v2) -> v2));
    }
    public static WSRespTypeEnum of(Integer type) {
        return cache.get(type);
    }
}
